<?php

namespace api\request;

class Request
{
    protected $fp = null;

    const BUFF_SIZE = 1024;

    public function __construct() {
        $this->fp = fopen("php://input", "r");
    }

    public function getBody() {
        $body = "";
        while (!feof($this->fp)) {
            $buf = fread($this->fp, self::BUFF_SIZE);
            if (empty($buf)) {
                break;
            }
            $body .= $buf;
        }
        return $body;
    }

    public function __destruct() {
        fclose($this->fp);
    }
}